zabbix_agent_source:
  file.managed:
    - name: /tmp/zabbix-agent.tgz
    - unless: test -e /tmp/zabbix-agent.tgz
    - user: root
    - goup: root
    - makedirs: True
    - source: salt://zabbix_agent/file/zabbix-agent.tgz
 
zabbix_agent_install:
  cmd.run:
    - cwd: /tmp
    - names:
      - tar -xzvf zabbix-agent.tgz -C /opt
    - unless: test -d /opt/zabbix-agent
    - require:
      - file: zabbix_agent_source

zabbix:
  user.present:
    - fullname: zabbix monitor
    - shell: /bin/sh
    - home: /home/zabbix
    #- groups:
    #  - zabbix

zabbix_agent_conf:
  file.managed:
    - name: /opt/zabbix-agent/etc/zabbix_agentd.conf
    - source: salt://zabbix_agent/file/zabbix_agentd_ubuntu.conf
    - requires:
      - zabbix_agent_install
      - zabbix

zabbix_agent_service:
  cmd.run:
    - names:
      - /opt/zabbix-agent/sbin/zabbix_agentd 
